package com.ysp;

/**
 * 饿汉式:这种是可以使用的
 */

/**
 *
 * @author ysp
 */
public class Singleton01 {

    private static final Singleton01 singleton01;

    static{
        singleton01 = new Singleton01();
    }

    private Singleton01(){}

    public static Singleton01 getInstance(){
        return singleton01;
    }
}

//上边的是使用静态代码块的方式赋值，这是直接赋值
//public class Singleton01 {
//    private static final Singleton01 singleton01 = new Singleton01();
//    private Singleton01(){}
//    public static Singleton01 getInstance(){
//        return singleton01;
//    }
//}
